cmake_minimum_required(VERSION 2.8)

if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
  if(DEFINED ENV{VITASDK})
    set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
  else()
    message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
  endif()
endif()

project(glestest)
include("${VITASDK}/share/vita.cmake" REQUIRED)

set(VITA_APP_NAME "Red Rectangle")
set(VITA_TITLEID  "VSDK00017")
set(VITA_VERSION  "01.00")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

include_directories(
  src
)

add_executable(${PROJECT_NAME}
  src/gles1test1.c
  src/print.c
)

add_definitions(-D__psp2__)
target_link_libraries(${PROJECT_NAME}
    #SCE
    SceDisplay_stub
    SceCtrl_stub
    SceNet_stub
    SceSysmodule_stub
    
    #PVR_PSP2
    libIMGEGL_stub_weak
    libgpu_es4_ext_stub_weak
    libGLESv1_CM_stub_weak
)

vita_create_self(${PROJECT_NAME}.self ${PROJECT_NAME} UNSAFE)
vita_create_vpk(${PROJECT_NAME}.vpk ${VITA_TITLEID} ${PROJECT_NAME}.self
  VERSION ${VITA_VERSION}
  NAME ${VITA_APP_NAME}

  #suprx
  FILE module/libGLESv1_CM.suprx module/libGLESv1_CM.suprx
  FILE module/libgpu_es4_ext.suprx module/libgpu_es4_ext.suprx
  FILE module/libIMGEGL.suprx module/libIMGEGL.suprx
  FILE module/libpvrPSP2_WSEGL.suprx module/libpvrPSP2_WSEGL.suprx
)
